<?php
namespace frontend\models;
use yii\base\Model;
use common\models\PreAdminInformation;


/*
**Team :
**Coding by 曾钰媛 1511240 170707
**This is the info form
*/
class InfoForm extends Model
{
    public  $Info_id;
    public  $Info_url;
    public  $Info_time;
    public  $Info_type;
    public  $Info_title;
    public  $Info_content;
    public  $status;
    public  $uid;
	
	public $_lastError= "";
	
	public function rules()
	{
		return [
		[['Info_title','Info_time','Info_content','Info_type'],'required'],
		];
	}
	
	public function attributeLabels(){
		return[
		'Info_id'=>'信息编号',
		'Info_content'=>'信息内容',
		'Info_time'=>'发布时间',
		'Info_title'=>'标题',
		'Info_type'=>'信息类型',
		'Info_url'=>'发布地址',
		'status'=>'状态',
		'uid'=>'发布者ID',
		];
		
	}
	
	public static function getList($cond,$curPage=1,$pageSize =5 ,$orderBy =['Info_id'=>SORT_DESC])
	{
		$model = new PreAdminInformation();
		$select =['Info_id','Info_title','Info_time','Info_type',
		'uid',
		];
		$query=$model->find()
		->select($select)
		->where($cond)
		->orderBy($orderBy);
		
		$res =$model->getPages($query,$curPage,$pageSize);
		//$res['data']=self::_formatList($res['data']);
		return $res;
	}
		
		
		
    /*public static function _formateList($data)
	{
		foreach($data as &$list){
			$list['tags']=[];
			if(isset($list['relate']))
		}
	}*/
}